
// This file is part of the delphi wrap "Irrlicht Engine".

#ifndef __C_READER_H_INCLUDED__
#define __C_READER_H_INCLUDED__

#include "IrrCompileConfig.h"

#ifdef DELPHI_WRAP

#include "CFileList.h"
#include "IFileArchive.h"

namespace irr
{
namespace io
{
	class CWrapFileArchive;

	class CReader : public CFileList
	{
		friend CWrapFileArchive;
	protected:
		IFileArchive *m_Archive;
	public:
		IFileArchive * getFileArchive()
		{
			return m_Archive;
		}
	public:
		//! opens a file by file name
		virtual IReadFile* createAndOpenFile(const io::path& filename) = 0;

		//! opens a file by index
		virtual IReadFile* createAndOpenFile(u32 index) = 0;

		//! returns the list of files
		virtual const IFileList* getFileList() const = 0;

		//! get the archive type
		virtual E_FILE_ARCHIVE_TYPE getType() const
		{
			return EFAT_UNKNOWN;
		};

	public:
		CReader(const io::path& path, bool ignoreCase, bool ignorePaths);
		virtual _STDCALL_ ~CReader(void);

	};

	class CWrapFileArchive : public IFileArchive
	{
	protected:
		CReader * m_OwnerReader;
	public:
		CWrapFileArchive(CReader *OwnerReader);
		virtual _STDCALL_ ~CWrapFileArchive();
	public:
		//! Opens a file based on its name
		/** Creates and returns a new IReadFile for a file in the archive.
		\param filename The file to open
		\return Returns A pointer to the created file on success,
		or 0 on failure. */
		virtual IReadFile* _STDCALL_ createAndOpenFile(const path& filename);

		//! Opens a file based on its position in the file list.
		/** Creates and returns
		\param index The zero based index of the file.
		\return Returns a pointer to the created file on success, or 0 on failure. */
		virtual IReadFile* _STDCALL_ createAndOpenFile(u32 index);

		//! Returns the complete file tree
		/** \return Returns the complete directory tree for the archive,
		including all files and folders */
		virtual const IFileList* _STDCALL_ getFileList() const;

		//! get the archive type
		virtual E_FILE_ARCHIVE_TYPE _STDCALL_ getType() const;
	};

} // end namespace io
} // end namespace irr


#endif // DELPHI_WRAP

#endif // __C_READER_H_INCLUDED__
